Why doesn't the following code compile?
template <class T>
void foo_bar(T =5 , T = 10 , T = 15)
{
}
int main()
{
foo_bar();
}
I get this error no matching function for call to 'foo_bar()'
. How to fix the error?
Prasoon Saurav :
The type of default arguments in a function cannot help in deducing the template type-parameter. T cannot be deduced in any case when you call the function like foo_bar() and so you get the error.\n\nSo try this foo_bar<int>();. In this case there won't be any such problem because the type of T is explicitly specified.",
2010-11-18T03:00:06